package com.groupbuying.sysconfig.dto.mini;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description 支付宝小程序模板消息消息体
 * @Auther Davidbieber
 * @Email davidbieber@163.com
 * @Date 2019/10/18 9:11 AM
 */
public class MiniAlipayInfo {

    /**
     * 支付宝用户UserId
     */
    private String toUserId;
    /**
     * 支付宝用户表单ID---formIdable｜tradeNo
     */
    private String formId;
    /**
     * 支付宝模版ID
     */
    private String userTemplateId;
    /**
     * 消息对应支付宝小程序页面路径
     */
    private String page;
    /**
     * 支付宝消息体
     */
    private List<MiniDataInfo> data;

    public MiniAlipayInfo(String toUserId, String formId, String userTemplateId, String page, List<MiniDataInfo> data) {
        this.toUserId = toUserId;
        this.formId = formId;
        this.userTemplateId = userTemplateId;
        this.page = page;
        this.data = data;
    }

    public String getToUserId() {
        return toUserId;
    }

    public void setToUserId(String toUserId) {
        this.toUserId = toUserId;
    }

    public String getFormId() {
        return formId;
    }

    public void setFormId(String formId) {
        this.formId = formId;
    }

    public String getUserTemplateId() {
        return userTemplateId;
    }

    public void setUserTemplateId(String userTemplateId) {
        this.userTemplateId = userTemplateId;
    }

    public String getPage() {
        return page;
    }

    public void setPage(String page) {
        this.page = page;
    }

    public List<MiniDataInfo> getData() {
        return data;
    }

    public void setData(List<MiniDataInfo> data) {
        this.data = data;
    }

    /**
     * list消息体添加公共消息体
     * @param dataInfo
     * @return
     */
    public MiniAlipayInfo addData(MiniDataInfo dataInfo){
        if(this.data==null){
            this.data=new ArrayList<>();
        }
        this.data.add(dataInfo);
        return this;
    }

    public static MiniAlipayInfo.MiniAlipayInfoBuilder builder(){
        return new MiniAlipayInfo.MiniAlipayInfoBuilder();
    }

    /**
     * 模板消息构造器
     */
    public static class MiniAlipayInfoBuilder{
        private String toUserId;
        private String formId;
        private String userTemplateId;
        private String page;
        private List<MiniDataInfo> data;

        MiniAlipayInfoBuilder(){};

        public MiniAlipayInfoBuilder toUserId(String toUserId) {
            this.toUserId = toUserId;
            return this;
        }

        public MiniAlipayInfoBuilder formId(String formId) {
            this.formId = formId;
            return this;
        }

        public MiniAlipayInfoBuilder userTemplateId(String userTemplateId) {
            this.userTemplateId = userTemplateId;
            return this;
        }

        public MiniAlipayInfoBuilder page(String page) {
            this.page = page;
            return this;
        }

        public MiniAlipayInfoBuilder data(List<MiniDataInfo> data) {
            this.data = data;
            return this;
        }

        public MiniAlipayInfo build(){
            return new MiniAlipayInfo(this.toUserId,this.formId,this.userTemplateId,this.page,this.data);
        }

        @Override
        public String toString(){
            return "MiniAlipayInfo.MiniAlipayInfoBuilder(toUserId="+this.toUserId+",userTemplateId="+this.userTemplateId+",page="+this.page+",formId="+this.formId+",data="+this.data+")";
        }
    }
}
